﻿/*
 *   IResolvable.cs
 *   Copyright (c) 2011 - BitFox Software and Ricardo Federico Villafañes
 *   Contact: federvillaf@hotmail.com
 *   
 *   Licensing: This product is covered by Microsoft Reciprocal License (MS-RL)
 *              see https://bitfoxeval.codeplex.com/license
*/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BitFox.Evaluator
{
    /// <summary>
    /// This interface CAN be used to derive objects that, at runtime, can provide properties or methods to
    /// the evaluation.
    /// </summary>
    /// <remarks>
    /// When the expression is something like:
    /// 
    ///    OBJ1.OBJ2.OBJ3
    /// 
    /// the evaluator must have a way to found OBJ2 'inside' OBJ1, and OBJ3 'inside' OBJ1.OBJ2. Normally, reflection
    /// is used to solve this problem but, if you need a way to virtualize the properties/methods inside an object,
    /// you can implement IResolvable in your object. In this way, rather than explore your object using reflection,
    /// the evaluator directly do calls to your object.
    /// </remarks>
    public interface IResolvable
    {
        /// <summary>
        /// Method called when the evaluator needs to solve a variable that was bind to an object
        /// </summary>
        /// <param name="name">The variable's name.</param>
        /// <param name="arrayIndexes">Indices, like an array, to reference the variable. It's not mandatory for each
        /// indice to be an integer.</param>
        /// <returns>The variable's value</returns>
        object SolveVariable(string name, object[] arrayIndexes);

        /// <summary>
        /// Method called when the evaluator needs to invoke a function that was bind to an object.
        /// </summary>
        /// <param name="name">The method's name</param>
        /// <param name="arguments">Arguments for method invocation.</param>
        /// <returns></returns>
        object SolveMethod(string name, object[] arguments);
    }
}
